package com.yeyks.rocketmq;

import com.aliyun.openservices.ons.api.PropertyKeyConst;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Properties;

@Data
@Slf4j
@Component
@ConfigurationProperties(prefix = "rocket-mq")
public class RocketMqConfig {

    private String accessKey;
    private String secretKey;
    private String nameSrvAddr;

    public Properties getProperties() {
        Properties properties = new Properties();
        properties.setProperty(PropertyKeyConst.AccessKey, this.accessKey);
        properties.setProperty(PropertyKeyConst.SecretKey, this.secretKey);
        //消费线程数量
        properties.setProperty(PropertyKeyConst.ConsumeThreadNums, "10");
        //设置发送超时时间，单位毫秒
        properties.setProperty(PropertyKeyConst.SendMsgTimeoutMillis, "3000");
        properties.setProperty(PropertyKeyConst.NAMESRV_ADDR, this.nameSrvAddr);
        return properties;
    }
}
